package com.ren.fm.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ren.fm.entity.ReclFmPraise;
import com.ren.fm.service.ReclFmPraiseService;
import com.ren.utils.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.management.Query;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author RZY
 * @since 2022-07-13
 */

@Api(tags = "FM点赞接口")
@RestController
@RequestMapping("/recl-fm/praise")
public class ReclFmPraiseController {

    @Autowired
    ReclFmPraiseService fmPraiseService;

    @ApiOperation(value = "查询指定用户的FM点赞量")
    @GetMapping("/fm-detail-user/{userId}")
    public R getFmPraiseCountByUserId(@PathVariable String userId) {
        int praiseCount = fmPraiseService.count(new QueryWrapper<ReclFmPraise>()
                .eq("praise_user_id", userId));
        return R.ok()
                .data("praiseCount", praiseCount);
    }

    @ApiOperation(value = "查询指定FM的点赞量")
    @GetMapping("/fm-detail/{fmId}")
    public R getFmPraiseCountByFmId(@PathVariable String fmId) {
        int praiseCount = fmPraiseService.count(new QueryWrapper<ReclFmPraise>()
                .eq("fm_id", fmId));
        return R.ok()
                .data("praiseCount", praiseCount);
    }
}

